home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 5895 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: news.ifm.liu.se!marcus
  2. From: marcus@lysator.liu.se (Marcus Comstedt)
  3. Newsgroups: comp.sys.amiga.programmer,comp.sys.amiga.applications,comp.unix.amiga
  4. Subject: Re: NEED HELP: Unix sh-script
  5. Date: 21 Mar 1996 15:34:43 GMT
  6. Message-ID: <4irsuj$bjb@newsy.ifm.liu.se>
  7. References: <4iph7u$cct@toad.stack.urc.tue.nl>
  8. NNTP-Posting-Host: tindra.lysator.liu.se
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=iso-8859-1
  11. Content-Transfer-Encoding: 8bit
  12. X-Newsreader: NN version 6.5.0 #24 (NOV)
  13.  
  14. eka@stack.urc.tue.nl (Eka Durmin) writes:
  15.  
  16. >Hello,
  17.  
  18. >I want to make a script which can be executed on an Unix. 
  19. >I have the same script (it does the same) for the Amiga shell-script:
  20. >  step1: 
  21. >    what: search a keyword in a textfile
  22. >    output: the line(s) (not the line numbers) containing this keyword
  23. >    Amiga: grep
  24. >    Unix: grep
  25. >  step2:
  26. >    what: get the #th line of a textfile (= output of step1)
  27. >    output: the line
  28. >    Amiga: Lines
  29. >    Unix: ???
  30.  
  31. sed -n "#p"
  32. (insert line number where # is)
  33.  
  34. >  step3:
  35. >    what: get the #th word of a line
  36. >    output: the word
  37. >    Amiga: GetWord
  38. >    Unix: ???
  39.  
  40. awk '{print $#}'
  41. (insert word number where # is)
  42.  
  43. Actually you can do both step 2 and 3 at the same time using:
  44.  
  45. awk '{if(NR==#1)print$#2}'
  46. (insert line number where #1 is, and work number where #2 is.)
  47.  
  48. / Marcus
  49. --
  50. --------------------------------------------------------------------------
  51. Marcus Comstedt                          Lysator Academic Computer Society
  52. marcus@lysator.liu.se                    Linko"ping University, Sweden  //
  53. ----------------------------------------------------------------------\X/-
  54.